<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		
		<link rel="stylesheet" href="./assets/styles/ui-lightness/ui.all.css" type="text/css" />
		
		<link rel="stylesheet" href="./assets/styles/ui-lightness/jquery-ui-1.7.3.custom.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/dialog.css" type="text/css" />
		
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
		<script src="assets/scripts/ui/ui.dialog.js" type="text/javascript"></script>
		
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<script type="text/javascript" src="./tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
		<script type="text/javascript" src="./assets/scripts/editor.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript" src="./assets/scripts/search.js"></script>
		<script type="text/javascript">
			$(function() {
				$('.message').fadeIn("slow");
				$('#btn-insert').click(function(){
					if (chkWeek()) {
						if( confirm('登録してよろしいですか？') ){
							document.fm.csv.value="copy";
							document.fm.submit();
						}
					}
				});
				$('#year4').change(function(){
					var year4 = this.value;
					var myDate = new Date();
					var nowtime =  myDate.getTime();
					$.get("mmap_week_ajax.php",{ y: year4,t : nowtime }, function(data){
						$("#matrix_cd").children().remove();
						$("#matrix_cd").append( data ); 
					});
				});	
				
				$('#year4t').change(function(){
					var year4 = this.value;
					var myDate = new Date();
					var nowtime =  myDate.getTime();
					$.get("mmap_week_ajax.php",{ y: year4,t : nowtime }, function(data){
						$("#matrix_cdt").children().remove();
						$("#matrix_cdt").append( data ); 
					});
				});
			});
			function chkWeek() {
				var weekid = $("#matrix_cd").val() ;
				if (weekid.length == 0){
					alert("コピー元の週を選択してください");
					return false;
				 }
				
				var weekidt = $("#matrix_cdt").val() ;
				if (weekidt.length == 0){
					alert("登録する週を選択してください");
					return false;
				 }
				
				if (weekid == weekidt) {
					alert("コピー元の週と登録する週は同じできない");
					return false;
					
				}
				
				return true;
			}
		</script>
		<link rel="stylesheet" type="text/css" href="./assets/styles/tablesorter.css" />
		<script type="text/javascript" src="./assets/scripts/tablesorter.js"></script>
	</head>
	<body id="">
{{$menu}}
{{$logout}}
		<div id="container"><div class="wrapper">
			<h2>パターン管理</h2>
			<ul class="submenu clearfix">
				<li><a href="tpattern_index.php">店別配布明細検索．更新</a></li>
				<li>店別配布明細登録</li>
				<li><a href="tpattern_export.php">店別配布明細出力</a></li>
				<li><a href="tpattern_shop.php">店別パターン部数ＤＬ</a></li>
				{{ if !($isG2_3) }} <li><a href="tpattern_delive.php">分納明細出力</a></li> {{/if}}
			</ul>
			<h3>店別配布明細登録</h3>
			{{ if $phase == 'input' }}
			<form name="fm" id="fm" method="get" action="tpattern_copy.php" >
<table class="formTable">
					<tr><th>※コピー元の週</th><td>
{{ html_options id='year4' name='year4' options=$year4 selected=$forms.year4 }} 年{{ $err.year4 }}&nbsp;&nbsp;&nbsp;
{{ html_options id='matrix_cd' name='matrix_cd' options=$week  selected=$forms.matrix_cd }}
	</td></tr>
<tr><th>※登録する週</th><td>
{{ html_options id='year4t' name='year4t' options=$year4t selected=$forms.year4t }} 年{{ $err.year4t }}&nbsp;&nbsp;&nbsp;
{{ html_options id='matrix_cdt' name='matrix_cdt' options=$weekt  selected=$forms.matrix_cdt }}
					</td></tr>
					</table>
				<p class="button" style="text-align:center">
					<button type="button" id="btn-insert" class="submit"><span>登録</span></button>
				</p>
				<input type="hidden" name="search" value="1" />
				<input type="hidden" name="csv" />
{{ /if }}
	
	{{ if $phase == 'complete' }}
	<p class="message">{{ $message }}</p>
				<ul>
					<li>>> <a href="tpattern_index.php">店別配布明細へ</a></li>
				</ul>
	{{ /if }}

		</div></div>
		{{ $footer }}
	</body>
</html>